package workers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import messaging.IMessagingHandler;
import messaging.JMSMessagingConstants;
import messaging.SoftwareDevelopmentMessagingHandler;
import model.Software;
import workerUIs.StepFrame;
import workflow.step.RepairStep;

public class RepairStepWorker extends AbstractStepSwingWorker {

	public RepairStepWorker(StepFrame frame,
			IMessagingHandler<Software> messagingHandler) {
		super(frame, messagingHandler);
	}

	@Override
	protected void doStep(Software software) {		
		new RepairStep().doStep(software);
	}
	
	public static void main(String[] args) {
		Logger logger = Logger.getLogger(RepairStepWorker.class.getCanonicalName());
		try	{		
			final StepFrame repairFrame = new StepFrame("Step4e: Repair", 800, 600);
			List<String> repairInputQueues = new ArrayList<String>();
			repairInputQueues.add(JMSMessagingConstants.TEST_OUTPUT_REPAIR_INPUT);
			List<String> repairOutputQueues = new ArrayList<String>();
			repairOutputQueues.add(JMSMessagingConstants.RELEASE_INPUT);
			final IMessagingHandler<Software> messagingHandler = new SoftwareDevelopmentMessagingHandler(repairFrame, repairInputQueues, repairOutputQueues);
			repairFrame.getNextButton().addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent arg0) {
					new RepairStepWorker(repairFrame, messagingHandler).execute();
				}
			});
		}
		catch (Exception e) {
			logger.log(Level.SEVERE, "Error during initialization: ", e);
		}
	}	

}
